package cn.enited.devtools.apiaggregator.dto;

import cn.enited.devtools.apiaggregator.consts.ErrorCode;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ToString(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
public class ActionResult implements Serializable {
    private static final long serialVersionUID = -8464679957201128618L;

    private int code;

    private String message;

    public static ActionResult of(int code, String message) {
        return new ActionResult(code, message);
    }

    public static ActionResult of(ErrorCode errorCode) {
        return of(errorCode.code(), errorCode.message());
    }
}
